package com.cityfood.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cityfood.mapper.CfCardDefaultMapper;
import com.cityfood.pojo.CfCardDefault;
import com.cityfood.pojo.CfCardDefaultExample;
import com.cityfood.pojo.CfCardDefaultExample.Criteria;
import com.cityfood.service.CardDefaultService;

@Service
public class CardDefaultServiceImpl implements CardDefaultService {

	@Autowired
	private CfCardDefaultMapper defaultMapper;

	@Override
	public List<CfCardDefault> selectCardDefaultByTypeId(Integer typeId) {
		CfCardDefaultExample example= new CfCardDefaultExample();
		Criteria criteria = example.createCriteria();
		criteria.andTypeIdEqualTo(typeId);
		List<CfCardDefault> list = defaultMapper.selectByExample(example);
		if (list.size()>0) {
			return list;
		}
		return null;
	}

	@Override
	public int insertCardDefault(CfCardDefault cardDefault) {
		int i = defaultMapper.insertSelective(cardDefault);
		return i;
	}

	@Override
	public int updateCardDefault(CfCardDefault cardDefault) {
		int i = defaultMapper.updateByPrimaryKeySelective(cardDefault);
		return i;
	}

	@Override
	public int deleteCardDefaultByTypeId(Integer typeId) {
		CfCardDefaultExample example=new CfCardDefaultExample();
		Criteria criteria = example.createCriteria();
		criteria.andTypeIdEqualTo(typeId);
		int i = defaultMapper.deleteByExample(example);
		return i;
	}

	@Override
	public int deleteCardDefault(Integer defaultId) {
		int i = defaultMapper.deleteByPrimaryKey(defaultId);
		return i;
	}

	@Override
	public List<CfCardDefault> selectCardDefault() {
		CfCardDefaultExample example= new CfCardDefaultExample();
		List<CfCardDefault> list = defaultMapper.selectByExample(example);
		if (list.size()>0) {
			return list;
		}
		return null;
	}
	
	
}
